package cn.geoportal.benoserver.mapper;

import cn.geoportal.benoserver.entity.IotInfo;
import cn.geoportal.benoserver.entity.vo.iot.IotInfoGet;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @Entity cn.geoportal.benoserver.entity.Iotinfo
 */
public interface IotinfoMapper extends BaseMapper<IotInfo> {
    /**
     * 1. 分页展示POI
     */
    IPage<IotInfo> queryIotInfoPage(Page<IotInfo> page, @Param(Constants.WRAPPER) QueryWrapper<IotInfo> wrapper);

    /**
     *
     * @param name
     * @param code
     * @param address
     * @param description
     * @param typeid
     * @param gltf_url
     * @param video_url
     * @param temp
     * @param humidity
     * @param height
     * @param lat
     * @param lng
     * @param geomStr
     * @return
     */
    @Select("INSERT INTO t_iotinfo(name, code, address, description, typeid, gltf_url, video_url, temp, humidity, height, lat, lng, geom) values(#{name}, #{code}, #{address}, #{description}, #{typeid}, #{gltf_url}, #{video_url}, #{temp}, #{humidity}, #{height}, #{lat}, #{lng}, ST_GeomFromText(#{geomStr}, 4326) ) RETURNING id")
    @Options(flushCache = Options.FlushCachePolicy.TRUE)
    int addIot(@Param("name") String name, @Param("code") String code, @Param("address") String address,
               @Param("description") String description, @Param("typeid") Integer typeid,
               @Param("gltf_url") String gltf_url, @Param("video_url") String video_url,
               @Param("temp") double temp, @Param("humidity") double humidity, @Param("height") double height,
               @Param("lat") double lat, @Param("lng") double lng, @Param("geomStr") String geomStr);

    /**
     *
     * @param id
     * @return
     */
    IotInfoGet getIotInfoById(Integer id);

    /**
     *
     * @param pt
     * @param radius
     * @return
     */
    List<IotInfo> findDistanceWithIn(String pt, double radius);
}




